package com.itheima.demo;

import com.itheima.domain.Orders;
import com.itheima.domain.User;
import com.itheima.utils.MapperUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class Demo2 {
    public static void main(String[] args) {
        //获取Sqlsession对象
        SqlSession session = MapperUtil.getsession();
        List<User> list = session.selectList("com.itheima.mapper.UserMapper.findUserAndOrders");
        for (User user : list) {
            System.out.println("用户名称：" + user.getUsername());
            List<Orders> ordersList = user.getOrdersList();
            for (Orders orders : ordersList) {
                System.out.println("订单编号：" + orders.getNumber());
            }
        }
        MapperUtil.close(session);
    }
}
